#include "manano_common.h"

#include "mdtx-online/indicator/indicator_type_s2_cov.h"
namespace indi = mdtx::online::indicator;

using rollcov = binary1<indi::rollcov>;
using rollcov_ew = binary1<indi::rollcov_ew>;
using rollcov_cu = binary1<indi::rollcov_cu>;

using rollcorr = binary1<indi::rollcorr>;
using rollcorr_ew = binary1<indi::rollcorr_ew>;
using rollcorr_cu = binary1<indi::rollcorr_cu>;

using rollbeta = binary1<indi::rollbeta>;
using rollbeta_cu = binary1<indi::rollbeta_cu>;

void bind_indi_s2_cov(py::module &m)
{
    auto mod = m.def_submodule("cov", "Rolling covariance and correlation");
    {
        auto v = py::class_<rollcov>(mod, "cov")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &rollcov::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollcov::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Rolling covariance
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<rollcov_ew>(mod, "cov_ew")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &rollcov_ew::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollcov_ew::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Rolling covariance, exponentially weighted
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<rollcov_cu>(mod, "cov_cu")
                     .def(py::init())
                     .def("run", &rollcov_cu::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollcov_cu::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Cumulative covariance)mydoc";
    }
    {
        auto v = py::class_<rollcorr>(mod, "corr")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &rollcorr::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollcorr::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Rolling correlation
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<rollcorr_ew>(mod, "corr_ew")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &rollcorr_ew::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollcorr_ew::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Rolling correlation, exponentially weighted
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<rollcorr_cu>(mod, "corr_cu")
                     .def(py::init())
                     .def("run", &rollcorr_cu::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollcorr_cu::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Cumulative correlation)mydoc";
    }
    {
        auto v = py::class_<rollbeta>(mod, "beta")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &rollbeta::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollbeta::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Rolling beta
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<rollbeta_cu>(mod, "beta_cu")
                     .def(py::init())
                     .def("run", &rollbeta_cu::run, py::arg("x"), py::arg("y"), "Run calc")
                     .def("run", &rollbeta_cu::run2, py::arg("x"), py::arg("y"), "Run batch calc");
        v.doc() = R"mydoc(
                    Cumulative beta)mydoc";
    }
}
